var util = require('../../../utils/util.js');
var api = require('../../../config/api.js');
var app = getApp();

var lastTime = null;
Page({
  data: {
    orderId: 0,
    orderInfo: {},
    dianpu: {},
    orderGoods: [],
    flag: false,
    handleOption: {}
  },
  onLoad: function (options) {
    // 页面初始化 options为页面跳转所带来的参数
    this.setData({
      orderId: options.id
    });
    this.getOrderDetail();
  },
  onPullDownRefresh() {
    wx.showNavigationBarLoading() //在标题栏中显示加载
    this.getOrderDetail();
    wx.hideNavigationBarLoading() //完成停止加载
    wx.stopPullDownRefresh() //停止下拉刷新
  },
  expandDetail: function () {
    let that = this;
    this.setData({
      flag: !that.data.flag
    })
  },
  getOrderDetail: function () {
    wx.showLoading({
      title: '加载中',
      mask: true
    });
    setTimeout(function () {
      wx.hideLoading()
    }, 2000);
    let that = this;
    util.request(api.MyOrderDetail, {
      orderId: that.data.orderId
    }).then(function (res) {
      if (res.result == 1) {
        that.setData({
          orderInfo: res.data,
          dianpu: res.data.dianpu,
        });
      }
      wx.hideLoading();
    });
  },
  
  test: function () {
    let that = this;
    wx.requestSubscribeMessage({
      tmplIds: app.globalData.tmplIds,
      success (res) {
        util.request(api.Ordermessage, {
          orderId: that.data.orderId
        }, 'POST').then(function (res) {
          debugger
          if (res.result == 1) {
           
          }
        });
       }
    })
  },

  onReady: function () {
    // 页面渲染完成
  },
  onShow: function () {
    // 页面显示
  },
  onHide: function () {
    // 页面隐藏
  },
  onUnload: function () {
    // 页面关闭
  }
})